<html>
  <head>
    <script>
      
      
      // Called when a message is passed.  We assume that the content script
      // wants to show the page action.
      function onRequest(request, sender, sendResponse) {
        try {
	        // does nothing. Why? console.log("onRequest request.id=" + request.id);
	        // input validaton on request.id is needed
	        pageActionOnClick = function (tab) {
        		console.log("pageActionOnClick request.id=" + request.id);
        		
        		var preferred_openid = "https://www.google.com/accounts/o8/id";
        		var myOpenID = localStorage["preferredOpenID"];
        		if (myOpenID) {
        			preferred_openid = myOpenID;
        		}
        		console.log("pageActionOnClick request.id=" + request.id);
        		var code = "var i=document.getElementById('"
        			+request.id+
        			"');if(i){i.setAttribute('value','"
        			+preferred_openid+
        			"');i.form.submit();}";
        		console.log("code="+code);
				chrome.tabs.executeScript(null, {"code": code});
      		};
	        chrome.pageAction.onClicked.addListener(pageActionOnClick); 
	        
	        // Show the page action for the tab that the sender (content script)
	        // was on.
	        chrome.pageAction.show(sender.tab.id);
	
	        // Return nothing to let the connection be cleaned up.
	        //sendResponse({});
	    } catch(e) {
	    	console.log("onRequest exception " + e);
	    }
      };

      // Listen for the content script to send a message to the background page.
      chrome.extension.onRequest.addListener(onRequest);
    </script>
  </head>
</html>